from typing import Optional, Any
from datetime import datetime
from pydantic import BaseModel


class UsersMeDTO(BaseModel):
    id: int
    name: str
    time_create: datetime
    cash: int
    residence: int
    strength: int
    education: int


class UsersOtherDTO(BaseModel):
    id: int
    name: str
    time_create: datetime
    residence: int
    strength: int
    education: int


class RegionDTO(BaseModel):
    id: int
    state_id: Optional[int]
    gold: int


class EntityRegionDTO(BaseModel):
    name: str
    lat: float
    lon: float


class StateDTO(BaseModel):
    id: int
    name: str
    dictator_id: Optional[int]
    taxes: int


def generate_sqlalchemy_dto(
        dto: type[BaseModel],
        model: Any) -> dict[str, Any]:
    return dto.model_validate(model, from_attributes=True)


def generate_many_sqlalchemy_dto(
        dto: type[BaseModel],
        models: list[Any]) -> list[dict[str, Any]]:
    return [generate_sqlalchemy_dto(dto, model) for model in models]
